package com.gopay.common.domain.user.identify;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.gopay.common.cipher.utils.SensitiveInfoUtils;
import com.gopay.common.domain.BaseEntity;

/**
 * 身份证认证渠道记录
 *
 * @PersCertChannelDTL.java
 * @author dak.wang
 * @2016年5月11日 下午3:08:42 www.gopay.com.cn Inc.All rights reserved.
 */
@Entity
@Table(name = "PERS_CERT_CHANNEL_DTL")
public class PersCertChannelDTL extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private Long id;
    private String certNo;
    private String custId;
    private String channelCode;
    private String status;
    private String createdOperId;
    private Date createdTs;
    private String lastUpdOperId;
    private Date lastUpdTs;
    private Integer version;
    private String cardNo;
    private String remark;
    private String mobile; //新增手机号 add by liuyong 20170417

    @Id
    @SequenceGenerator(name = "PERS_CERT_CHANNEL_DTL_SEQ_GENERATOR", sequenceName = "PERS_CERT_CHANNEL_DTL_SEQ", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PERS_CERT_CHANNEL_DTL_SEQ_GENERATOR")
    @Column(name = "ID")
    public Long getId() {
        return id;
    }

    @Column(name = "CERT_NO", length = 150)
    public String getCertNo() {
        //return certNo;
        /**
         * modified by zyt 2017-4-10 自动重新加密并解密返回
         */
        this.certNo = SensitiveInfoUtils.autoReencrypt(this.certNo);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.certNo);
    }

    @Column(name = "CUST_ID", length = 10)
    public String getCustId() {
        return custId;
    }

    @Column(name = "CHANNEL_CODE", length = 20)
    public String getChannelCode() {
        return channelCode;
    }

    @Column(name = "STATUS", length = 2)
    public String getStatus() {
        return status;
    }

    @Column(name = "CREATED_OPER_ID", length = 10)
    public String getCreatedOperId() {
        return createdOperId;
    }

    @Column(name = "CREATED_TS")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCreatedTs() {
        return createdTs;
    }

    @Column(name = "LAST_UPD_OPER_ID", length = 10)
    public String getLastUpdOperId() {
        return lastUpdOperId;
    }

    @Column(name = "LAST_UPD_TS")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getLastUpdTs() {
        return lastUpdTs;
    }

    @Column(name = "VERSION", precision = 22, scale = 0)
    public Integer getVersion() {
        return version;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setCertNo(String certNo) {
        //this.certNo = certNo;
        /**
         * modified by zyt 2017-4-10 写操作的时候做加密
         */
        this.certNo = SensitiveInfoUtils.smartEncryptWithCheck(certNo);
    }

    public void setCustId(String custId) {
        this.custId = custId;
    }

    public void setChannelCode(String channelCode) {
        this.channelCode = channelCode;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public void setCreatedOperId(String createdOperId) {
        this.createdOperId = createdOperId;
    }

    public void setCreatedTs(Date createdTs) {
        this.createdTs = createdTs;
    }

    public void setLastUpdOperId(String lastUpdOperId) {
        this.lastUpdOperId = lastUpdOperId;
    }

    public void setLastUpdTs(Date lastUpdTs) {
        this.lastUpdTs = lastUpdTs;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Column(name = "CARD_NO", length = 150 ,unique = true)
    public String getCardNo() {
        /**
    	 * modify by zyt，在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 * 2017-1-5
    	 */
    	this.cardNo = SensitiveInfoUtils.autoReencrypt(cardNo);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.cardNo);
    }

    public void setCardNo(String cardNo) {
        /**
    	 * modified by zyt，判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 * 2017-1-5
    	 */
    	this.cardNo = SensitiveInfoUtils.smartEncryptWithCheck(cardNo);
    }
    @Column(name = "REMARK", length = 200 )
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Column(name = "CUST_MOB", length = 150 )
    public String getMobile() {
    	  /**
    	 * modify by zyt，在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 * 2017-1-5
    	 */
    	this.mobile = SensitiveInfoUtils.autoReencrypt(mobile);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.mobile);
    }

    public void setMobile(String mobile) {
    	   /**
    	 * modified by zyt，判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 * 2017-1-5
    	 */
    	this.mobile = SensitiveInfoUtils.smartEncryptWithCheck(mobile);
    }
}
